'''
* This is the projet for Brtc LlmOps Platform
* @Author Leon-liao <liaosiliang@alltman.com>
* @Description //TODO 
* @File: 6_llm_chat_model_with_flow.py
* @Time: 2025/10/22
* @All Rights Reserve By Brtc
'''
from datetime import datetime

import dotenv

from langchain_core.prompts import ChatPromptTemplate
from langchain_openai import ChatOpenAI

dotenv.load_dotenv()
#1、编排Prompt
prompt =ChatPromptTemplate.from_messages([
    ("system", "你是OpenAI 开发的机器人, 请回答用户的问题, 现在的时间是{now}"),
    ("human","{query}")
]).partial(now = datetime.now)


#2、创建大预言模型
llm = ChatOpenAI(model="gpt-4o-mini")

ai_message = llm.stream(prompt.invoke({"query":"现在几点钟？请帮忙写一篇<厉害了我的国>观后感。 1000 字左右！"}))
for one_message in ai_message:
    print(one_message.content, flush=True, end='')

print("\nover!")